<template>
  <view class="comment-content">
    <textarea
      class="comment-area"
      v-model="comment"
      placeholder="请输入正文"
      
    />
	<!-- focus="true" -->
    <button
      class="submit"
      :disabled="!canSubmit"
      :class="canSubmit ? 'actived' : ''"
      @click="submitComment"
    >
      提交
    </button>
    <shopro-auth-modal></shopro-auth-modal>
  </view>
</template>

<script>
export default {
  data() {
    return {
      comment: "",
      canSubmit: false,
    };
  },
  onLoad() {
    console.log(this.$Route.query, "----");
  },
  methods: {
    submitComment() {
      let that = this;
      const params = {
        id: that.$Route.query.id,
        com_content: that.comment,
        type: that.$Route.query.comId ? 1 : 0,
      };
      if (that.$Route.query.comId) {
        params.com_id = that.$Route.query.comId;
      }
      that.$https("doctindex.articleComment", params).then((res) => {
        if (res.code === 1) {
          uni.showToast({
            title: "评论成功",
            duration: 2000,
            icon: "none",
            position: "bottom",
            complete: function () {
              setTimeout(() => {
                uni.navigateBack();
              }, 2000);
            },
          });
        }
      });
    },
  },
  watch: {
    comment(val) {
      this.canSubmit = val !== "";
    },
  },
};
</script>

<style lang="scss">
.comment-content {
  padding: 30rpx;
  box-sizing: border-box;
  height: 100%;
  background: #ffffff;
  display: flex;
  justify-content: center;
  .comment-area {
    min-height: 400rpx;
    padding: 28rpx;
    width: 100%;
    background: #f5f5f5;
    border-radius: 20rpx;
  }
  .submit {
    position: fixed;
    bottom: 40rpx;
    border-radius: 40rpx;
    line-height: 80rpx;
    width: 690rpx;
    border: none;
    background: #eeeeee;
  }
  uni-button:after {
    border: none;
  }
  .actived {
    background: rgba(223, 185, 130, 1);
    color: #ffffff;
  }
}
</style>
